<template>
	<view class="mian">
		<!-- #ifdef MP-WEIXIN -->
			<navbar :bgColor="bgColor" :btnColors='btnColor' title="邀请有礼" :isGoBack="true" :isNotice="true" :visible="true"></navbar>
		<!-- #endif -->	
		<view class="share_title">
			<view class="flex share_one">
				 <img src="/static/mine/share/Vector_855.png" alt="" class="share_icon" />
				 <text class="propress">邀请流程</text>
				 <img src="/static/mine/share/Vector_856.png" alt="" class="share_icon" />
			</view>
			<view class="flex share_two">
				<view class="flex flex-direction justify-center align-center">
					 <img src="/static/mine/share/Frame@2x.png" alt="" class="share_Frame" />
					 <view class="propress_title">
					 	<text class="propress">向好友</text>
						<text class="propress">发送邀请</text>
					 </view>
					 
				</view>
				<view class="flex flex-direction justify-center align-center ml-30">
					 <img src="/static/mine/share/Group9128@2x.png" alt="" class="Group_icon middel_icon" />
					  
				</view>
				<view class="flex flex-direction justify-center align-center">
					 <img src="/static/mine/share/Frame@2x.png" alt="" class="share_Frame" />					 
					 <view class="propress_title">
					 	<text class="propress">好友登陆小程序</text>
					 	<text class="propress">并完成注册并交易</text>
					 </view>
				</view>
				<view class="flex flex-direction justify-center align-center">
					 <img src="/static/mine/share/Group9128@2x.png" alt="" class="Group_icon middel_icon" />
					  
				</view>
				<view class="flex flex-direction justify-center align-center">
					 <img src="/static/mine/share/Frame@2x.png" alt="" class="share_Frame" />
					  <view class="propress_title">
					  	<text class="propress">现金到账</text>
					  	<text class="propress">或消费券到账</text>
					  </view>
				</view>
				
			</view>
		</view>	
		
		<view class="flex share_three">
			 <image :src="userInfo.bannner_list.url" mode="scaleToFill" class="banner_info"></image>
		</view>
		
		
		<view class="about-button flex-direction" style="background-color: #ffffff">
			<button class="about-button-sharey" style="background:#36B3E9 ;color: #ffffff;;height: 88rpx;text-align: center;line-height: 25px;" @click="()=>share_postor()">
				<view class=" ml-10">点击分享海报</view>
			</button>
			
			<view class="flex " style="margin-top: 60px;">								
				<button class="about-button-alipay" style="background:#FFFFFF ;color: #222222;;height: 88rpx;text-align: center;line-height: 88rpx;" @click="()=>share_group()">					
					<view class=" ml-10">我的团员</view>
				</button>
				
				<button class="about-button-alipays" style="background:#36B3E9;border: none;color: #ffffff;height: 88rpx;text-align: center;line-height: 88rpx;" @click="()=>share_center()">
					<view class=" ml-10">我的收入</view>
				</button>
			
			</view>			
		</view>	
		
		
	</view>
</template>

 
<script>
	import cityData from '@/utils/city.js'
	export default {
		data() {
			return {
				...getApp().globalData.config,	
				
				userInfo:{}
				
			};
		},
		onLoad() {
			
		},
		onShow() {
			this.query_member()
		},		
		methods: {
			...getApp().globalData.function,
			
			//分享中心
			share_center(){
				this.$routers.router('/pages/pagesuser/share_center/index','navigateTo') 
			},
			
			//团员信息
			share_group(){
				this.$routers.router('/pages/pagesuser/share_groups/index','navigateTo') 
			},
			
			//获取用户信息
			query_member(){
				let that=this
				let user_info=uni.getStorageSync('userInfo');
				let obj_data={
					token:user_info.token,
				    login_type:'app'
				};
				this.$http.getUser(obj_data).then(res=>{	
					console.log('res.data',res.data.is_group)
					if(res.resCode=='9999'){	
					    that.userInfo=res.data
					}				
				})		
			},
			
			//分享
			share_postor(){
				
				//uni.hideLoading();
				uni.showLoading({
					title: '海报生成中…'
				});
				
				
				let that=this
				let user_info=uni.getStorageSync('userInfo');
				let obj_data={
					token:user_info.token,
				    id:that.userInfo.bannner_list.id
				};
				this.$http.shopPoster(obj_data).then(res=>{	
					console.log('res.data',res)
					if(res.resCode=='9999'){	
					    let path_url=res.data.url						
						
						uni.downloadFile({
							url:  path_url,//必须是接口返回的路径，才可以保存到手机相册
							success(res) {
								console.log(res,'res下载返回图片路径');
								uni.hideLoading();
								// 图片保存到本地
								uni.saveImageToPhotosAlbum({
									filePath: res.tempFilePath,
									success(data) {
										uni.showToast({
											title: '保存成功',
											icon: 'success',
											duration: 2000
										});
									},
									fail(err) {
										console.log(err.errMsg);
										if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
											uni.showToast({
												title: '请允许访问相册后重试',
												icon: 'none',
												duration: 1000
											});
											setTimeout(() => {
												uni.openSetting();
											}, 1000);
										}
									},
									complete(res) {
										console.log('complete');
									}
								});
							}
						})						
					}else{
						that.$showToast(res.resMessage)	
					}				
				})		
			}
			
			
			
			
			
			
		},
	};
</script>
 
<style>
	
		@import url("./index.css");
</style>